package br.com.linhadotempo.util;

import java.util.ArrayList;
import java.util.List;

public class Mensagens {

	private String success;
	private String error;
	private String warning;
	private List<String> errors;
	private List<String> warnings;

	private Mensagens() {
		this.errors = new ArrayList<String>();
		this.warnings = new ArrayList<String>();
	}

	public static Mensagens getInstance() {
		return MensagensHolder.INSTANCE;
	}

	private static class MensagensHolder {
		private static final Mensagens INSTANCE = new Mensagens();
	}

	public String getSuccess() {
		return success;
	}

	public void setSuccess(String success) {
		this.success = success;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public String getWarning() {
		return warning;
	}

	public void setWarning(String warning) {
		this.warning = warning;
	}

	public List<String> getErrors() {
		return errors;
	}

	public void setErrors(List<String> errors) {
		this.errors = errors;
	}

	public List<String> getWarnings() {
		return warnings;
	}

	public void setWarnings(List<String> warnings) {
		this.warnings = warnings;
	}

	public void clean() {
		this.success = "";
		this.warning = "";
		this.error = "";
		this.warnings.clear();
		this.errors.clear();
	}
	
	public void tratarExceptions(Exception e){
		this.getErrors().add(e.getMessage());
	}
}
